import mplfinance as mpf
import pandas as pd
import akshare as ak

print("starting mplfinance .....")
df = ak.stock_zh_a_hist(
    symbol="000001",
    period="daily",
    start_date="20230601",
    end_date="20231101",
    adjust="",
)
df = df.iloc[:, 0:6]
df.日期 = pd.to_datetime(df.日期)

# 列名记得这样定义好
df.columns = ["Date", "Open", "Close", "High", "Low", "Volume"]
df.set_index("Date", inplace=True)

two_points = [("2023-08-04", 12.53), ("2023-11-01", 10.56)]


more_points = [
    ("2023-06-01", 11.59),
    ("2023-06-08", 11.83),
    ("2023-07-11", 11.21),
    ("2023-08-04", 12.03),
    ("2023-11-01", 10.56),
]

mpf.plot(
    df,
    style="yahoo",
    mav=(5, 8, 13),
    volume=True,
    hlines=dict(hlines=[11, 12], colors=["green", "red"], linestyle="-."),
    alines=dict(alines=more_points, colors=["b", "r", "c", "k", "g"]),
    type="candle",
)


print("end")
